﻿#region << 版 本 注 释 >>
/*
     * ========================================================================
     * Copyright Notice  2010-2021 TideBuy.com All rights reserved .
     * ========================================================================
     * 机器名称：DESKTOP-VJFB8FV 
     * 文件名：  StockInViewModel 
     * 版本号：  V1.0.0.0 
     * 创建人：  徐一贺 
     * 创建时间： 2021/3/6 14:09:18 
     * 描述    :
     * =====================================================================
     * 修改时间：2021/3/6 14:09:18 
     * 修改人  ： 徐一贺
     * 版本号  ： V1.0.0.0 
     * 描述    ：
*/
#endregion
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using CoilIntelStorage.Commands;
using CoilIntelStorage.Models;
using CoilIntelStorage.Utils;
using Prism.Mvvm;

namespace CoilIntelStorage.ViewModels
{
    public class StockInViewModel : BindableBase
    {
        

        //用来接收保存按钮命令
        public ICommand SaveCommand
        {
            get
            {
                return new DelegateCommand((obj) =>
                {
                    Goods goods = new Goods();
                });
            }
        }

        public StockInViewModel() {
            LoadWorkableStockList();
        }

        private List<Stock> positionViewModels;
        public List<Stock> PositionViewModels { 
            get => positionViewModels; 
            set => SetProperty(ref positionViewModels, value); 
        }

        /// <summary>
        /// 加载可用的空位置列表
        /// </summary>
        private void LoadWorkableStockList() {
            DataTable dataTable = DbHelper.GetTable("SELECT * FROM stock");
            PositionViewModels = new List<Stock>();
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                Stock stock = new Stock();
                DataRow dataRow = dataTable.Rows[i];
                stock.Id = Convert.ToInt32(dataRow["id"]);
                stock.Name = dataRow["name"].ToString();
                stock.Status = Convert.ToInt32(dataRow["status"]);
                stock.Lock_status = Convert.ToInt32(dataRow["lock_status"]);
                stock.Lock_type = Convert.ToInt32(dataRow["lock_Type"]);
                PositionViewModels.Add(stock);
            }
        }
    }
}
